package org.judking.CarKeeper.command.EarlyWarning;

import org.judking.CarKeeper.service.StcActivityService;
import org.judking.CarKeeper.service.VoiceService.VoiceType;

public class WarmUpCheck {
	private double intakeAirTempBound = 10;
	private double timeAfterIgnitionBound = 180;			//3min
	private double speedBound = 40;
	private Counter counter = new Counter(40, true);
	
	public void check(
			IntakeAirTemperatureDetector intakeAirTemperatureDetector,
			TimeAfterIgnitionDetector timeAfterIgnitionDetector,
			SpeedDetector speedDetector) {
		check(intakeAirTemperatureDetector.getCurIntakeAirTemp(),
				timeAfterIgnitionDetector.getTime(),
				speedDetector.getCurSpeed());
	}
	
	private void check(	double curIntakeAirTemp, 
										double curTimeAfterIgnition,
										double curSpeed)			{
		if(curIntakeAirTemp < intakeAirTempBound && 
			curTimeAfterIgnition < timeAfterIgnitionBound &&
			curSpeed > speedBound)			{
			if(counter.tick())		{
				StcActivityService.mkVoice(VoiceType.WARM_UP);
			}
		}
	}

	public double getIntakeAirTempBound() {
		return intakeAirTempBound;
	}

	public void setIntakeAirTempBound(double intakeAirTempBound) {
		this.intakeAirTempBound = intakeAirTempBound;
	}

	public double getTimeAfterIgnitionBound() {
		return timeAfterIgnitionBound;
	}

	public void setTimeAfterIgnitionBound(double timeAfterIgnitionBound) {
		this.timeAfterIgnitionBound = timeAfterIgnitionBound;
	}

	public double getSpeedBound() {
		return speedBound;
	}

	public void setSpeedBound(double speedBound) {
		this.speedBound = speedBound;
	}

}
